<template>
    <div ref="body">
        <Form :label-width="120" inline>
            <Form-item label="查询方式:">
                <Select v-model="queryParam.isMember" style="width: 200px" @on-change="changeIsMember">
                    <Option value="0">按户</Option>
                    <Option value="1">按人</Option>
                </Select>
            </Form-item>
            <Form-item label="属地区划:">
                <area-linkage :areaCode.sync="queryParam.azaa0001"></area-linkage>
            </Form-item>
            <Form-item label="户主姓名:">
                <Input v-model="queryParam.azcp0003" placeholder="请输入户主姓名" style="width:200px"/>
            </Form-item>

            <Form-item label="户主身份证号码:">
                <Input v-model="queryParam.azcp0001" placeholder="请输入户主身份证号码" style="width:200px"/>
            </Form-item>
            <span v-if="show">
                <Form-item label="家庭编号:">
                    <Input v-model="queryParam.azdf0001" placeholder="请输入家庭编号" style="width:200px"/>
                </Form-item>

                <Form-item label="低保证号:">
                    <Input v-model="queryParam.ssca0014" placeholder="请输入低保证号" style="width:200px"/>
                </Form-item>

                <Form-item label="受理编号:">
                    <Input v-model="queryParam.ssca0061" placeholder="请输入受理编号" style="width:200px"/>
                </Form-item>

                <Form-item label="批准时间:">
                    <DatePicker type="daterange" split-panels v-model="queryParam.ssca0006_time"
                                placeholder="请选择批准时间" style="width: 200px" :editable="false"></DatePicker>
                </Form-item>

                <Form-item label="致贫原因:" v-if="queryParam.isMember!='1'">
                    <c-dict-select v-model="queryParam.ssca0013" dictCode="poorreason"
                                   placeholder="请选择致贫原因"/>
                </Form-item>

                <Form-item label="成员姓名:" v-if="queryParam.isMember=='1'">
                    <Input v-model="queryParam.user_azcp0003" placeholder="请输入成员姓名" style="width:200px"/>
                </Form-item>

                <Form-item label="成员证件号码:" v-if="queryParam.isMember=='1'">
                    <Input v-model="queryParam.user_azcp0001" placeholder="请输入成员证件号码" style="width:200px"/>
                </Form-item>

                <Form-item label="性别:" v-if="queryParam.isMember=='1'">
                    <c-dict-select v-model="queryParam.azcp0004" dictCode="sex" placeholder="请选择性别"/>
                </Form-item>

                <Form-item label="民族:" v-if="queryParam.isMember=='1'">
                    <c-dict-select v-model="queryParam.azcp0007" dictCode="nation"
                                   placeholder="请选择民族"/>
                </Form-item>

                <Form-item label="健康状况:" v-if="queryParam.isMember=='1'">
                    <c-dict-select v-model="queryParam.azcp0009" dictCode="health"
                                   placeholder="请选择健康状况"/>
                </Form-item>

                <Form-item label="残疾类别:" v-if="queryParam.isMember=='1'">
                    <c-dict-select v-model="queryParam.azcp0504" dictCode="disabilitytype"
                                   placeholder="请选择残疾类别"/>
                </Form-item>

                <Form-item label="残疾等级:" v-if="queryParam.isMember=='1'">
                    <c-dict-select v-model="queryParam.azcp0505" dictCode="disabilityclass"
                                   placeholder="请选择残疾等级"/>
                </Form-item>

                <Form-item label="救助金额:" v-if="queryParam.isMember=='1'">
                    <InputNumber v-model="queryParam.azcp0548_begin" :min="0" placeholder="" style="width:93px"/>
                    ~
                    <InputNumber v-model="queryParam.azcp0548_end" :min="0" placeholder="" style="width:93px"/>
                </Form-item>

                <Form-item label="年龄:" v-if="queryParam.isMember=='1'">
                    <InputNumber v-model="queryParam.age_begin" :min="0" placeholder="" style="width:93px"/>
                    ~
                    <InputNumber v-model="queryParam.age_end" :min="0" placeholder="" style="width:93px"/>
                </Form-item>
            </span>
            <div style="display: inline-block;cursor:pointer" @click="showHidden">
                <template v-if="show">
                    <Form-item label="收起条件" style="cursor:pointer">
                        <div class="ivu-form-item">
                        <span class="ivu-input-suffix">
                          <Icon type="ios-arrow-up"/>
                        </span>
                        </div>
                    </Form-item>
                </template>
                <template v-else>
                    <Form-item label="展开条件" style="cursor:pointer">
                        <div class="ivu-form-item">
                        <span class="ivu-input-suffix">
                            <Icon type="ios-arrow-down"/>
                        </span>
                        </div>
                    </Form-item>
                </template>
            </div>
            <Row>
                  <span style="float: right;margin-right: 8px">
                 <Button type="primary" style="" @click="searchQueryNew">查询</Button>
                 <Button type="primary" style="margin-left: 8px" @click="searchResetNew">重置</Button>
                     </span>
            </Row>
        </Form>

        <div id="statistics">
            <div v-if="queryParam.ssca0012!='300'">
                <span>查询统计:</span>
                <span>{{name}}总户数 [ {{statistics.familyNum}} ] 户</span>
                <span>保障人口总数 [ {{statistics.memberNum}} ] 人</span>
                <span>总高龄补贴金额 [ {{statistics.sumSsbi0008}} ] 元</span>
                <span v-if="queryParam.ssca0012!='200'">总救助金额 [ {{statistics.helpmoney}} ] 元</span>
                <span v-if="queryParam.ssca0012!='200'">总金额 [ {{statistics.money}} ] 元</span>
            </div>
            <div v-else>
                <span>查询统计:</span>
                <span>{{name}}总户数 [ {{statistics.familyNum}} ] 户</span>
                <span>家庭人口总数 [ {{statistics.memberNum}} ] 人</span>
            </div>
        </div>

        <div>
            <vxe-table border
                       resizable
                       row-id="id"
                       :row-key="true"
                       show-overflow="tooltip"
                       highlight-hover-row
                       align="center"
                       header-align="center"
                       ref="xTree"
                       :loading="Loading"
                       :data="tableData">
                <vxe-table-column field="ssca0043" title="属地区划" align="center" width="220" fixed="left"
                                  :formatter="renderAreaName"/>
                <vxe-table-column field="azcp0003" title="户主姓名" align="center" width="100" fixed="left"/>
                <vxe-table-column field="azcp0001" title="户主身份证号码" align="center" width="200" fixed="left"/>
                <vxe-table-column field="user_azcp0003" title="成员姓名" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="user_azcp0001" title="成员证件号码" align="center" width="180"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="age" title="年龄" align="center" width="100" v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="ssca0014" title="低保证号" align="center" width="140"/>
                <vxe-table-column field="ssca0011" title="银行账号" align="center" width="140"
                                  v-if="queryParam.isMember=='0'"/>
                <vxe-table-column field="azdf0001" title="家庭编号" align="center" width="180"/>
                <vxe-table-column field="ssca0061" title="受理编号" align="center" width="160"/>
                <vxe-table-column field="ssca0049" title="家庭月总收入" align="center" width="200"
                                  v-if="queryParam.isMember=='0'"/>
                <vxe-table-column field="ssca0052" title="保障人口数" align="center" width="140"
                                  v-if="queryParam.isMember=='0'"/>
                <vxe-table-column field="azdf0008" title="家庭住址" align="center" width="140"/>
                <vxe-table-column field="ssca0042" title="保障标准" align="center" width="140"/>
                <vxe-table-column field="ssbi0004" title="分类救助上浮类别" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="ssbi0005" title="分类救助上浮金额" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="ssbi0008" title="高龄补贴金额" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0548" title="救助金额" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="fullmoney" title="总金额" align="center" width="140"
                                  v-if="queryParam.isMember=='0'"/>
                <vxe-table-column field="ssca0006" title="批准时间" align="center" width="140" :formatter="renderTime"
                                  v-if="queryParam.ssca0012!='300'"/>
                <vxe-table-column field="ssca0028" title="批准时间" align="center" width="140" :formatter="renderTime"
                                  v-if="queryParam.ssca0012=='300'"/>
                <vxe-table-column field="ssca0044" title="家庭基础收入" align="center" width="140"
                                  v-if="queryParam.isMember=='0'"/>
                <vxe-table-column field="ssca0045" title="家庭赡抚养费" align="center" width="140"
                                  v-if="queryParam.isMember=='0'"/>
                <vxe-table-column field="ssca0046" title="家庭财产" align="center" width="140"
                                  v-if="queryParam.isMember=='0'"/>
                <vxe-table-column field="ssca0047" title="家庭支出" align="center" width="140"
                                  v-if="queryParam.isMember=='0'"/>
                <vxe-table-column field="ssca0003" title="申请时间" align="center" width="140" :formatter="renderTime"/>
                <vxe-table-column field="ssca0033" title="变更时间" align="center" width="140" :formatter="renderTime"/>
                <vxe-table-column field="azcp0517" title="与申请人关系" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0004" title="性别" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0013" title="户籍类别" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0007" title="民族" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0008" title="文化程度" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0009" title="健康状况" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0504" title="残疾类别" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0505" title="残疾等级" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="azcp0502" title="劳动能力丧失情况" align="center" width="140"
                                  v-if="queryParam.isMember=='1'"/>
                <vxe-table-column field="ssca0013" title="致贫原因" align="center" width="140"/>
                <vxe-table-column field="ssca0032" title="数据来源" align="center" width="140" :formatter="renderSsca0032"/>
                <vxe-table-column title="操作" align="center" width="140" fixed="right">
                    <template #default="{row}">
                        <Button type="default" @click="searchDetail(row)">查看详情</Button>
                    </template>
                </vxe-table-column>
            </vxe-table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
        <application-modal ref="modal"/>
    </div>
</template>

<script>
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import {getAction, postAction} from '@/api/request'
    import applicationModal from '../db_application_history/applicationModal'

    export default {
        name: "search-rescue100100-list",
        mixins: [CommonMixin],
        components: {applicationModal},
        data() {
            return {
                queryParam: {
                    isMember: "0",
                    azcp0548_begin: null,
                    azcp0548_end: null,
                    age_begin: null,
                    age_end: null,
                    ssca0002: "100",
                    ssca0012: "100",
                },
                name: "",
                statistics: {
                    familyNum: 0,
                    memberNum: 0,
                    sumSsbi0008: 0,
                    helpmoney: 0,
                    money: 0
                },
                Loading: true,
                show: false,
                url: {
                    list: "/api/ac/subsistence/ss12001Service/searchRescue",
                },
            }
        },
        methods: {
            renderSsca0032(h) {
                if (h.cellValue == '200') {
                    return '历史导入数据';
                } else if (h.cellValue == '300') {
                    return '推送数据';
                } else if (h.cellValue == '100') {
                    return '填报数据';
                }
            },
            searchQueryNew() {
                var time = this.queryParam.ssca0006_time;
                if (time) {
                    if (time[0]) {
                        this.queryParam.ssca0006_begin = this.DateFormat(time[0], 'YYYY-MM-DD') + " 00:00:00";
                    }else{
                        this.queryParam.ssca0006_begin ="";
                    }
                    if (time[1]) {
                        this.queryParam.ssca0006_end = this.DateFormat(time[1], 'YYYY-MM-DD') + " 23:59:59";
                    }else{
                        this.queryParam.ssca0006_end ="";
                    }
                }
                this.loadData(1);
            },
            showHidden() {
                this.show = !this.show;
            },
            changeIsMember(v) {
                //this.show = false;
                this.queryParam.isMember = v;
                this.queryParam.azcp0548_begin = null;
                this.queryParam.azcp0548_end = null;
                this.queryParam.age_begin = null;
                this.queryParam.age_end = null;
                this.loadData(1);
            },
            searchResetNew() {
                var ssca0002 = this.queryParam.ssca0002;
                var ssca0012 = this.queryParam.ssca0012;
                var unssca0016100 = this.queryParam.unssca0016100;
                var ssca0016100 = this.queryParam.ssca0016100;
                this.queryParam = {};
                this.queryParam.isMember = "0";
                this.queryParam.ssca0002 = ssca0002;
                this.queryParam.ssca0012 = ssca0012;
                this.queryParam.unssca0016100 = unssca0016100;
                this.queryParam.ssca0016100 = ssca0016100;
                this.loadData(1);
            },
            loadData(arg) {
                if (arg == 1) {
                    this.pageNo = 1;
                }
                let that = this;
                that.Loading = true;
                let param = Object.assign({}, this.queryParam);
                let url = this.url.list;
                param.pageNo = this.pageNo;
                param.pageSize = this.pageSize;
                postAction(url, param).then((res) => {
                    if (res.data.errcode != 0) {
                        this.$Message.error(res.data.errmsg);
                    } else {
                        that.tableData = res.data.data.pageList.results;
                        that.dataCount = res.data.data.pageList.totalRecord;
                        that.statistics = res.data.data.statistics;
                    }
                }).finally(() => {
                    that.Loading = false;
                })
            },
            searchDetail(row) {
                row.processinstid = row.ywgl004;
                var width = this.$refs.body.clientWidth;
                this.$refs.modal.edit(row);
                this.$refs.modal.width = width + 40;
                this.$refs.modal.key = this.uuid();
            },
            edit(queryParam, name) {
                this.queryParam.ssca0002 = queryParam.ssca0002;
                this.queryParam.ssca0012 = queryParam.ssca0012;
                this.queryParam.unssca0016100 = queryParam.unssca0016100;
                this.queryParam.ssca0016100 = queryParam.ssca0016100;
                this.name = name;
                this.findAreaList();
            }
        },

    }
</script>

<style scoped>
    .paging {
        float: right;
        margin-top: 10px;
    }

    /deep/ .ivu-upload-list {
        display: none;
    }

    /deep/ .ivu-table-cell {
        padding-right: 0px;
        padding-left: 0px;
    }

    #statistics {
        height: 50px;
        line-height: 50px;
        width: 100%;
        color: red;
        font-size: 16px;
    }

    #statistics span {
        padding-left: 10px;
        padding-right: 10px;
    }

</style>
